﻿namespace CGM
{
	public class Filename
	{
		// properties
		public string Path
		{
			get { return m_strPath; }
			set { m_strPath = value; }
		}

		public string Name
		{
			get { return m_strName; }
			set { m_strName = value; }
		}

		public string Extension
		{
			get { return m_strExtension; }
			set { m_strExtension = value; }
		}

		public string PathName
		{
			get { return m_strPath + m_strName; }
			set
			{
				if (value == null)
				{
					m_strPath = null;
					m_strName = null;
				}
				else
				{
					int iNameStart = value.LastIndexOf('\\') + 1;
					m_strPath = value.Substring(0, iNameStart);
					m_strName = value.Substring(iNameStart);
				}
			}
		}

		public string NameExtension
		{
			get { return m_strName + m_strExtension; }
			set
			{
				if (value == null)
				{
					m_strName = null;
					m_strExtension = null;
				}
				else
				{
					int iExtStart = value.LastIndexOf('.');
					m_strName = value.Substring(0, iExtStart);
					m_strExtension = value.Substring(iExtStart);
				}
			}
		}

		public string PathNameExtension
		{
			get { return m_strPath + m_strName + m_strExtension; }
			set
			{
				if (value == null)
				{
					m_strPath = null;
					m_strName = null;
					m_strExtension = null;
				}
				else
				{
					int iNameStart = value.LastIndexOf('\\') + 1;
					int iExtStart = value.LastIndexOf('.');
					m_strPath = value.Substring(0, iNameStart);
					m_strName = value.Substring(iNameStart, iExtStart - iNameStart);
					m_strExtension = value.Substring(iExtStart);
				}
			}
		}

		// methods
		public Filename()
		{
			Path = null;
			Name = null;
			Extension = null;
		}

		public Filename(string _strPath, string _strName, string _strExtension)
		{
			Path = _strPath;
			Name = _strName;
			Extension = _strExtension;
		}

		public Filename(string _strPathNameExtension)
		{
			PathNameExtension = _strPathNameExtension;
		}

		// fields
		private string m_strPath;
		private string m_strName;
		private string m_strExtension;
	}
}
